using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;

namespace AutoUpdater
{
    internal static class Program
    {
        private static Mutex mutex = null;
        
        [STAThread]
        static void Main()
        {
            const string mutexName = "AutoUpdaterSingleInstance";
            bool createdNew;
            
            mutex = new Mutex(true, mutexName, out createdNew);
            
            if (!createdNew)
            {
                MessageBox.Show("程序已经在运行中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
            
            mutex?.ReleaseMutex();
            Environment.Exit(0);
        }
    }
}